﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DAL;
using BLL;

public partial class ERDS_LRBZ : System.Web.UI.Page
{

    BLLEeds BE = new BLLEeds();
    string errMsg = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        //string time="";
        //if(this.DDLBZ. =="BC1")
        //{
        //    time="2-10"
        //}
        //else if()


        //    time ,DateTime 

        //        1
        
        
        if (!IsPostBack)
        {
            DateTime dt = System.DateTime.Now;
            this.DateLR.Value = dt.AddDays(-1).ToString("yyyy-MM-dd");

            string BZ = "";
            string TimeBZ = "";
            if (this.DDLBZ.SelectedValue == "BC1")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 5:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC2")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 11:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC3")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 17:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC4")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 23:00:00");
            }

            BZ = BE.SelectBZ(TimeBZ, out errMsg);

            string[] point = new string[45];

            point[1] = "1fdlbz";
            point[2] = "2fdlbz";
            point[3] = "3fdlbz";
            point[4] = "4fdlbz";
            point[5] = "1jbckdlbz";
            point[6] = "2jbckdlbz";
            point[7] = "3jbckdlbz";
            point[8] = "4jbckdlbz";
            point[9] = "1tlbdlbz";
            point[10] = "2tlbdlbz";
            point[11] = "3tlbdlbz";
            point[12] = "4tlbdlbz";
            point[13] = "1nqqbslbz";
            point[14] = "2nqqbslbz";
            point[15] = "3nqqbslbz";
            point[16] = "4nqqbslbz";
            point[17] = "1zqllbz";
            point[18] = "2zqllbz";
            point[19] = "3zqllbz";
            point[20] = "4zqllbz";
            point[21] = "1zyslbz";
            point[22] = "2zyslbz";
            point[23] = "3zyslbz";
            point[24] = "4zyslbz";
            point[25] = "1gyysbz";
            point[26] = "2gyysbz";
            point[27] = "3gyysbz";
            point[28] = "4gyysbz";
            point[29] = "1bjysbz";
            point[30] = "2bjysbz";
            point[31] = "3bjysbz";
            point[32] = "4bjysbz";

            ArrayList list = BE.SelectSGLRBZ(DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd"), point, BZ, out  errMsg);

            string[] val = (string[])list[1];

            this.fdlbz1.Value = val[1];
            this.fdlbz2.Value = val[2];
            this.fdlbz3.Value = val[3];
            this.fdlbz4.Value = val[4];
            this.jbckdlbz1.Value = val[5];
            this.jbckdlbz2.Value = val[6];
            this.jbckdlbz3.Value = val[7];
            this.jbckdlbz4.Value = val[8];
            this.tlbdlbz1.Value = val[9];
            this.tlbdlbz2.Value = val[10];
            this.tlbdlbz3.Value = val[11];
            this.tlbdlbz4.Value = val[12];
            this.nqqbslbz1.Value = val[13];
            this.nqqbslbz2.Value = val[14];
            this.nqqbslbz3.Value = val[15];
            this.nqqbslbz4.Value = val[16];
            this.zqllbz1.Value = val[17];
            this.zqllbz2.Value = val[18];
            this.zqllbz3.Value = val[19];
            this.zqllbz4.Value = val[20];
            this.zyslbz1.Value = val[21];
            this.zyslbz2.Value = val[22];
            this.zyslbz3.Value = val[23];
            this.zyslbz4.Value = val[24];
            this.gyysbz1.Value = val[25];
            this.gyysbz2.Value = val[26];
            this.gyysbz3.Value = val[27];
            this.gyysbz4.Value = val[28];
            this.bjysbz1.Value = val[29];
            this.bjysbz2.Value = val[30];
            this.bjysbz3.Value = val[31];
            this.bjysbz4.Value = val[32];

            this.show.InnerHtml = "";
        }
    }

        protected void LRBRQ_Click(object sender, EventArgs e)
        {
            string[] point = new string[45];

            //DateTime dt = System.DateTime.Now;
            //this.DateLR.Value = dt.AddDays(-1).ToString("yyyy-MM-dd");

            string BZ = "";
            string TimeBZ = "";
            if (this.DDLBZ.SelectedValue == "BC1")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 5:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC2")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 11:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC3")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 17:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC4")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 23:00:00");
            }

            BZ = BE.SelectBZ(TimeBZ, out errMsg);

            point[1] = "1fdlbz";
            point[2] = "2fdlbz";
            point[3] = "3fdlbz";
            point[4] = "4fdlbz";
            point[5] = "1jbckdlbz";
            point[6] = "2jbckdlbz";
            point[7] = "3jbckdlbz";
            point[8] = "4jbckdlbz";
            point[9] = "1tlbdlbz";
            point[10] = "2tlbdlbz";
            point[11] = "3tlbdlbz";
            point[12] = "4tlbdlbz";
            point[13] = "1nqqbslbz";
            point[14] = "2nqqbslbz";
            point[15] = "3nqqbslbz";
            point[16] = "4nqqbslbz";
            point[17] = "1zqllbz";
            point[18] = "2zqllbz";
            point[19] = "3zqllbz";
            point[20] = "4zqllbz";
            point[21] = "1zyslbz";
            point[22] = "2zyslbz";
            point[23] = "3zyslbz";
            point[24] = "4zyslbz";
            point[25] = "1gyysbz";
            point[26] = "2gyysbz";
            point[27] = "3gyysbz";
            point[28] = "4gyysbz";
            point[29] = "1bjysbz";
            point[30] = "2bjysbz";
            point[31] = "3bjysbz";
            point[32] = "4bjysbz";

            ArrayList list = BE.SelectSGLRBZ(DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd"), point, BZ, out  errMsg);

            string[] val = (string[])list[1];

            this.fdlbz1.Value = val[1];
            this.fdlbz2.Value = val[2];
            this.fdlbz3.Value = val[3];
            this.fdlbz4.Value = val[4];
            this.jbckdlbz1.Value = val[5];
            this.jbckdlbz2.Value = val[6];
            this.jbckdlbz3.Value = val[7];
            this.jbckdlbz4.Value = val[8];
            this.tlbdlbz1.Value = val[9];
            this.tlbdlbz2.Value = val[10];
            this.tlbdlbz3.Value = val[11];
            this.tlbdlbz4.Value = val[12];
            this.nqqbslbz1.Value = val[13];
            this.nqqbslbz2.Value = val[14];
            this.nqqbslbz3.Value = val[15];
            this.nqqbslbz4.Value = val[16];
            this.zqllbz1.Value = val[17];
            this.zqllbz2.Value = val[18];
            this.zqllbz3.Value = val[19];
            this.zqllbz4.Value = val[20];
            this.zyslbz1.Value = val[21];
            this.zyslbz2.Value = val[22];
            this.zyslbz3.Value = val[23];
            this.zyslbz4.Value = val[24];
            this.gyysbz1.Value = val[25];
            this.gyysbz2.Value = val[26];
            this.gyysbz3.Value = val[27];
            this.gyysbz4.Value = val[28];
            this.bjysbz1.Value = val[29];
            this.bjysbz2.Value = val[30];
            this.bjysbz3.Value = val[31];
            this.bjysbz4.Value = val[32];

            this.show.InnerHtml = "";
        }

        protected void LRBSave_Click(object sender, EventArgs e)
        {
            string[] arrpoint = new string[45];
            string[] val = new string[45];

            arrpoint[1] = "1fdlbz";
            arrpoint[2] = "2fdlbz";
            arrpoint[3] = "3fdlbz";
            arrpoint[4] = "4fdlbz";
            arrpoint[5] = "1jbckdlbz";
            arrpoint[6] = "2jbckdlbz";
            arrpoint[7] = "3jbckdlbz";
            arrpoint[8] = "4jbckdlbz";
            arrpoint[9] = "1tlbdlbz";
            arrpoint[10] = "2tlbdlbz";
            arrpoint[11] = "3tlbdlbz";
            arrpoint[12] = "4tlbdlbz";
            arrpoint[13] = "1nqqbslbz";
            arrpoint[14] = "2nqqbslbz";
            arrpoint[15] = "3nqqbslbz";
            arrpoint[16] = "4nqqbslbz";
            arrpoint[17] = "1zqllbz";
            arrpoint[18] = "2zqllbz";
            arrpoint[19] = "3zqllbz";
            arrpoint[20] = "4zqllbz";
            arrpoint[21] = "1zyslbz";
            arrpoint[22] = "2zyslbz";
            arrpoint[23] = "3zyslbz";
            arrpoint[24] = "4zyslbz";
            arrpoint[25] = "1gyysbz";
            arrpoint[26] = "2gyysbz";
            arrpoint[27] = "3gyysbz";
            arrpoint[28] = "4gyysbz";
            arrpoint[29] = "1bjysbz";
            arrpoint[30] = "2bjysbz";
            arrpoint[31] = "3bjysbz";
            arrpoint[32] = "4bjysbz";

            val[1] = this.fdlbz1.Value;
            val[2] = this.fdlbz2.Value;
            val[3] = this.fdlbz3.Value;
            val[4] = this.fdlbz4.Value;
            val[5] = this.jbckdlbz1.Value;
            val[6] = this.jbckdlbz2.Value;
            val[7] = this.jbckdlbz3.Value;
            val[8] = this.jbckdlbz4.Value;
            val[9] = this.tlbdlbz1.Value;
            val[10] = this.tlbdlbz2.Value;
            val[11] = this.tlbdlbz3.Value;
            val[12] = this.tlbdlbz4.Value;
            val[13] = this.nqqbslbz1.Value;
            val[14] = this.nqqbslbz2.Value;
            val[15] = this.nqqbslbz3.Value;
            val[16] = this.nqqbslbz4.Value;
            val[17] = this.zqllbz1.Value;
            val[18] = this.zqllbz2.Value;
            val[19] = this.zqllbz3.Value;
            val[20] = this.zqllbz4.Value;
            val[21] = this.zyslbz1.Value;
            val[22] = this.zyslbz2.Value;
            val[23] = this.zyslbz3.Value;
            val[24] = this.zyslbz4.Value;
            val[25] = this.gyysbz1.Value;
            val[26] = this.gyysbz2.Value;
            val[27] = this.gyysbz3.Value;
            val[28] = this.gyysbz4.Value;
            val[29] = this.bjysbz1.Value;
            val[30] = this.bjysbz2.Value;
            val[31] = this.bjysbz3.Value;
            val[32] = this.bjysbz4.Value;

            string BZ;
            string TimeBZ = "";

            if (this.DDLBZ.SelectedValue == "BC1")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 5:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC2")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 11:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC3")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 17:00:00");
            }
            else if (this.DDLBZ.SelectedValue == "BC4")
            {
                TimeBZ = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd 23:00:00");
            }

            BZ = BE.SelectBZ(TimeBZ, out errMsg);

            string date = DateTime.Parse(this.DateLR.Value).ToString("yyyy-MM-dd");

            bool flag = BE.SaveSGLRBZ(arrpoint, val, date, BZ, out errMsg);

            if (flag == true)
                this.show.InnerHtml = "记录保存成功...";
            else
                this.show.InnerHtml = "保存失败...";

        }
           
    
}
